home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 1 / Gold Medal Software Volume 1 (Gold Medal) (1994).iso / prog / tpwprog7.arj / STATUS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-07-02  |  2.5 KB  |  117 lines

  1. { status.pas -- Modeless "status" dialog box }
  2.  
  3. unit Status;
  4.  
  5. interface
  6.  
  7. {$R status.res}
  8.  
  9. uses WinTypes, WinProcs, WObjects;
  10.  
  11. const
  12.  
  13.   statusID = 'STATUS';   { Dialog resource ID }
  14.  
  15. type
  16.  
  17.   PStatus = ^TStatus;
  18.   TStatus = object(TDialog)
  19.     ContinueFlag: Boolean;
  20.     constructor Init(AParent: PWindowsObject; AName: PChar);
  21.     procedure ChangeTitle(Title: PChar);
  22.     procedure BeginStatus(StatusLabel: PChar);
  23.     procedure EndStatus;
  24.     procedure Update; virtual;
  25.     procedure Update1(P: PChar);
  26.     procedure Update2(P: PChar);
  27.     procedure Cancel(var Msg: TMessage);
  28.       virtual id_First + id_Cancel;
  29.     function Continue: Boolean;
  30.   end;
  31.  
  32.  
  33. implementation
  34.  
  35. const
  36.  
  37.   id_Label    = 101;
  38.   id_Status_1 = 102;
  39.   id_Status_2 = 103;
  40.  
  41.  
  42. {- Construct and initialize TStatus dialog object }
  43. constructor TStatus.Init(AParent: PWindowsObject; AName: PChar);
  44. begin
  45.   TDialog.Init(AParent, AName);
  46.   EnableKBHandler;
  47.   ContinueFlag := true
  48. end;
  49.  
  50. {- Change dialog caption to a new title }
  51. procedure TStatus.ChangeTitle(Title: PChar);
  52. begin
  53.   SetWindowText(HWindow, Title)
  54. end;
  55.  
  56. {- Start new modeless dialog operation. Display status label }
  57. procedure TStatus.BeginStatus(StatusLabel: PChar);
  58. begin
  59.   SendDlgItemMsg(id_Label, wm_SetText, 0, LongInt(StatusLabel));
  60.   Show(sw_ShowNormal);
  61.   SetFocus(HWindow);
  62.   ContinueFlag := true
  63. end;
  64.  
  65. {- Hide the dialog window }
  66. procedure TStatus.EndStatus;
  67. begin
  68.   Show(sw_Hide)
  69. end;
  70.  
  71. {- Allow keyboard and mouse operation }
  72. procedure TStatus.Update;
  73. var
  74.   Msg: TMsg;
  75. begin
  76.   while PeekMessage(Msg, 0, 0, 0, pm_Remove) do
  77.     if not IsDialogMessage(HWindow, Msg) then
  78.     begin
  79.       TranslateMessage(Msg);
  80.       DispatchMessage(Msg)
  81.     end
  82. end;
  83.  
  84. {- Display string P in first update area }
  85. procedure TStatus.Update1(P: PChar);
  86. begin
  87.   Update;
  88.   SendDlgItemMsg(id_Status_1, wm_SetText, 0, LongInt(P))
  89. end;
  90.  
  91. {- Display string P in second update area }
  92. procedure TStatus.Update2(P: PChar);
  93. begin
  94.   Update;
  95.   SendDlgItemMsg(id_Status_2, wm_SetText, 0, LongInt(P))
  96. end;
  97.  
  98. {- Handle cancel button }
  99. procedure TStatus.Cancel(var Msg: TMessage);
  100. begin
  101.   ContinueFlag := false
  102. end;
  103.  
  104. {- Return state of continue flag. False = operation canceled }
  105. function TStatus.Continue: Boolean;
  106. begin
  107.   Continue := ContinueFlag
  108. end;
  109.  
  110. end.
  111.  
  112.  
  113. {--------------------------------------------------------------
  114.   Copyright (c) 1991 by Tom Swan. All rights reserved.
  115.   Revision 1.00    Date: 5/15/1991
  116. ---------------------------------------------------------------}
  117.